package com.heima.minio;

import io.minio.MinioClient;
import io.minio.ObjectWriteResponse;
import io.minio.PutObjectArgs;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class MinioTest {

    public static void main(String[] args) throws Exception {
        //1.获取minio客户端
        MinioClient minioClient=MinioClient.builder()
                .credentials("minio","minio123")//用户及密码
                .endpoint("http://192.168.8.100:9000/")
                .build();
        //2.上传文件
        FileInputStream fileInputStream = new FileInputStream(new File("D:\\list.html"));

        PutObjectArgs putObjectArgs=PutObjectArgs.builder()
                .bucket("leadnews")//桶名称
                .object("list.html")//上传文件名
                .contentType("text/html")//上传文件格式
                .stream(fileInputStream,fileInputStream.available(),-1)//具体文件流
                .build();
        ObjectWriteResponse response = minioClient.putObject(putObjectArgs);
    }
}